package cn.lsh.mapper;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class TempMapper extends Mapper<LongWritable, Text, Text, Text> {
	Text yearMonth = new Text();
	Text dayTemp = new Text();

	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		//2020-04-10 10:18:42 45c
		String line = value.toString();
		yearMonth.set(line.substring(0, 7));
		String day = line.substring(8, 10);
		String temp = line.substring(20, line.length() - 1);
		dayTemp.set(day + " " + temp);
		context.write(yearMonth, dayTemp);
	}
}
